package com.bc.bcsellerapihttp.controller;

import com.bc.bcapi.service.T_Account_logService;
import com.bc.bcapi.service.T_User_seller_bonusService;
import com.bc.bcapi.service.T_User_seller_infoService;
import com.bc.bcmodel.SellerUserInfo;
import com.bc.bcmodel.domain.T_User_buyer_infoModel;
import com.bc.bcmodel.domain.T_User_seller_infoModel;
import com.bc.bcmodel.req.AccountMyAccountInfoReq;
import com.bc.bcmodel.req.AccountMyWalletReq;
import com.bc.bcmodel.req.SellerBonusReq;
import com.bc.bcmodel.req.UserSetHeadFigureReq;
import com.bc.bcsellerapihttp.common.UserContext;
import com.bc.commonentity.common.JsonResult;
import com.bc.commonentity.enums.HttpReturnRnums;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Name SellerContrller
 * @Description
 * @Author douhaichao
 * @Date 2018/8/18 21:17
 * @Version 1.0
 **/
@RestController
@RequestMapping("seller")
@Api(value = "卖家用户接口")
public class SellerContrller {

    @Autowired
    T_User_seller_bonusService t_user_seller_bonusService;

    @Autowired
    T_Account_logService t_account_logService;
    @Autowired
    T_User_seller_infoService t_user_seller_infoService;

    @ApiOperation("设置bonus")
    @RequestMapping(value = "setbonus", method = RequestMethod.POST)
    public JsonResult setBonus(@RequestBody List<SellerBonusReq> req) throws Exception {
        SellerUserInfo loginInfo = UserContext.getCurrentContext().getLoginInfo();
        if (loginInfo == null) {
            JsonResult js = new JsonResult();
            js.setCode(0);
            return js;
        }
        return t_user_seller_bonusService.setBonus(req, loginInfo.getUser_id());
    }

    @ApiOperation("查询bonus")
    @RequestMapping(value = "getbonus", method = RequestMethod.GET)
    public JsonResult getBonus() {
        SellerUserInfo loginInfo = UserContext.getCurrentContext().getLoginInfo();
        if (loginInfo == null) {
            JsonResult js = new JsonResult();
            js.setCode(0);
            return js;
        }
        return t_user_seller_bonusService.getBonus(loginInfo.getUser_id());
    }

    @ApiOperation("头象变更")
    @RequestMapping(value = "setheadfigure", method = RequestMethod.POST)
    public JsonResult setHeadFigure(@RequestBody UserSetHeadFigureReq req) {
        SellerUserInfo userInfo =
                UserContext.getCurrentContext().getLoginInfo();
        if (userInfo == null) {
            return new JsonResult(HttpReturnRnums.NOT_LOGIN);
        }
        req.setUser_id(userInfo.getUser_id());
        return t_user_seller_infoService.setHeadFigure(req);
    }
//
//    TODO 徐建
//    @ApiOperation("账务明细")
//    @RequestMapping(value = "getmyaccountinfo", method = RequestMethod.POST)
//    public JsonResult getMyAccountInfo(@RequestBody AccountMyAccountInfoReq req) {
//        T_User_seller_infoModel loginInfo = UserContext.getCurrentContext().getLoginInfo();
//        if (loginInfo == null) {
//            JsonResult js = new JsonResult();
//            js.setCode(0);
//            return js;
//        }
//        req.setUser_id(loginInfo.getUser_id());
//        return t_account_logService.getMyAccountInfo(req);
//    }

}
